package org.pms.dao.impl;

import org.pms.dao.UserLoginDao;
import org.pms.entity.UserLogin;
import org.pms.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Date 2022-12-13
 * @Author 祝世栩
 *
 * 用户登录Dao接口实现
 */
public class UserLoginDaoImpl implements UserLoginDao {
    Connection connection = null ;
    PreparedStatement ps = null ;
    ResultSet rs = null ;
    UserLogin userLogin = null ;
    @Override
    public UserLogin UserLoginSelectNamePhonePwd(String Name, String Phone, String Pwd) {
        String sql = "select UserName,UserPhone,UserPwd,UserState from UserLogin " +
                " where (UserName=? or UserPhone=?) and UserPwd=? and UserState=? ";
        try {
            connection = DbUtil.getConnection();
            ps = connection.prepareStatement(sql);
            ps.setString(1,Name);
            rs = ps.executeQuery();

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        return userLogin;
    }
}
